#include "ControlInterface.h"
//------------------------------------------------------------------------
const float ControlInterface::MAX_MOVEMENT_DISTANCE = 50.0f;
//------------------------------------------------------------------------
// Kon-/Destruktoren
//------------------------------------------------------------------------
DummyControlling::DummyControlling(IrrlichtDevice * const dev)
	: Entity(dev)
{
	this->m_device->setEventReceiver(&this->m_evtReceiver);
}
DummyControlling::~DummyControlling()
{
	this->m_device->setEventReceiver(nullptr);
}
//------------------------------------------------------------------------
// Methoden
//------------------------------------------------------------------------
void DummyControlling::poll()
{
	auto dPos = this->m_evtReceiver.GetMouseState().deltaPosition;

	this->m_cursorPosition += dPos;

	this->m_dPos = vector2df(static_cast<float>(dPos.X) / MAX_MOVEMENT_DISTANCE, static_cast<float>(dPos.Y) / MAX_MOVEMENT_DISTANCE);
}
//------------------------------------------------------------------------
bool DummyControlling::pitchCameraUp() const
{
	return this->m_evtReceiver.IsKeyDown(KEY_UP);
}
//------------------------------------------------------------------------
bool DummyControlling::pitchCameraDown() const
{
	return this->m_evtReceiver.IsKeyDown(KEY_DOWN);
}
//------------------------------------------------------------------------
bool DummyControlling::yawCameraRight() const
{
	return this->m_evtReceiver.IsKeyDown(KEY_RIGHT);
}
//------------------------------------------------------------------------
bool DummyControlling::yawCameraLeft() const
{
	return this->m_evtReceiver.IsKeyDown(KEY_LEFT);
}
//------------------------------------------------------------------------
vector2df const& DummyControlling::moveCursor() const
{
	return this->m_dPos;
}
//------------------------------------------------------------------------
bool DummyControlling::rollObjectRight() const
{
	return this->m_evtReceiver.IsKeyDown(KEY_KEY_E);
}
//------------------------------------------------------------------------
bool DummyControlling::rollObjectLeft() const
{
	return this->m_evtReceiver.IsKeyDown(KEY_KEY_Q);
}
//------------------------------------------------------------------------
bool DummyControlling::pitchObjectFront() const 
{
	return this->m_evtReceiver.IsKeyDown(KEY_KEY_W);
}
//------------------------------------------------------------------------
bool DummyControlling::pitchObjectBack() const
{
	return this->m_evtReceiver.IsKeyDown(KEY_KEY_S);
}
//------------------------------------------------------------------------
bool DummyControlling::yawObjectLeft() const
{
	return this->m_evtReceiver.IsKeyDown(KEY_KEY_A);
}
//------------------------------------------------------------------------
bool DummyControlling::yawObjectRight() const
{
	return this->m_evtReceiver.IsKeyDown(KEY_KEY_D);
}
//------------------------------------------------------------------------
bool DummyControlling::toggleSelection() const 
{
	return this->m_evtReceiver.GetMouseState().LeftButtonDown;
}
//------------------------------------------------------------------------
vector2di DummyControlling::getCursorPosition() const
{
	return this->m_cursorPosition;
}
